(function () {
  var myChart = echarts.init(document.querySelector(".right3"));
  let data = [
    {
      value: 57,
      name: "图例1",
      itemStyle: {
        normal: {
          color: "#087EE0",
          label: {
            show: true,
            formatter: "{c}%",
            textStyle: { color: "#fff" },
          },
        },
      },
    },
    {
      value: 14,
      name: "图例2",
      itemStyle: {
        normal: {
          color: "#79ADF9",
          label: {
            show: true,
            formatter: "{c}%",
            textStyle: { color: "#fff" },
          },
        },
      },
    },
    {
      value: 29,
      name: "图例3",
      itemStyle: {
        normal: {
          color: "#C4D5FF",
          label: {
            show: true,
            formatter: "{c}%",
            textStyle: { color: "#fff" },
          },
        },
      },
    },
    {
      value: 29,
      name: "图例4",
      itemStyle: {
        normal: {
          color: "#C4D5FF",
          label: {
            show: true,
            formatter: "{c}%",
            textStyle: { color: "#fff" },
          },
        },
      },
    },
    {
      value: 29,
      name: "图例5",
      itemStyle: {
        normal: {
          color: "#C4D5FF",
          label: {
            show: true,
            formatter: "{c}%",
            textStyle: { color: "#fff" },
          },
        },
      },
    },
  ];
  var a = 0;
  for (let i = 0; i < data.length; i++) {
    a += data[i].value;
  }
  data.push({
    value: a,
    name: "__other",
    itemStyle: { normal: { color: "rgba(0,0,0,.0)" } },
  });
  let option = {
    legend: {
      data: ["图例1", "图例2", "图例3", "图例4", "图例5"],
      textStyle: {
        color: "#fff",
      },
    },
    series: [
      {
        height: 400,

        name: "分配",
        type: "pie",
        startAngle: -180,
        radius: "60%",
        center: ["50%", "40%"],
        data: data.sort(function (a, b) {
          return a.value - b.value;
        }),
        itemStyle: {
          emphasis: {
            shadowBlur: 10,
            shadowOffsetX: 0,
            shadowColor: "rgba(0, 0, 0, 0.5)",
          },
        },
        label: {
          normal: {
            show: true,
          },
        },
        labelLine: {
          lineStyle: {
            color: "green",
          },
          smooth: 0.2,
          length: 10,
          length2: 20,
        },
        animationType: "scale",
        animationEasing: "elasticOut",
        animationDelay: function (idx) {
          return Math.random() * 200;
        },
      },
    ],
  };
  myChart.setOption(option);
  window.addEventListener("resize", function () {
    myChart.resize();
  });
})();
